package com.guqinghan.guqinghan_03_sqllite;

import android.content.Context;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;

@Database(entities = {Person.class},version = 1,exportSchema = false)
public abstract class PersonDatabase extends RoomDatabase {

    public abstract PersonDao getPersonDao();

    private static  PersonDatabase database;

    // 单例模式，返回database
    private static PersonDatabase getInstance(Context context){

        if (database==null){
            database = Room.databaseBuilder(context.getApplicationContext(),PersonDatabase.class,"PersonDatabase").build();
        }
        return database;
    }
}
